home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1996-11-19 | 6.3 KB | 221 lines | [ TEXT/MPS ]
# # File: LinkSharedLibrary # # Contains: Script to link a shared library # # Copyright: © 1992-1994 by Apple Computer, Inc., all rights reserved. # # Set OutFile "" Set InObj "" Set SymFile "" Set XCoffSymFile 0 Set PPCLinkOpts "-outputformat xcoff" Set MakeSymOptions "-w -r" Set MakePefOptions "" Set Error 0 Set NoMerge 0 Set Symbols 0 Set model "-model far" Set PPC 0 if "{TempFolder}" !~ // Set Scratch "{TempFolder}" else if "{CPlusScratch}" !~ // Set Scratch "{CPlusScratch}" else Set Scratch "`directory`" end LOOP If "{1}" == "" || "{1}" !~ /-≈/ Break; Else If "{1}" =~ /-obj/ Set InObj "{2}"; Shift 2; Continue Else If "{1}" =~ /-lib/ Set OutFile "{2}"; Shift 2; Continue Else If "{1}" =~ /-link/ Shift; Break; Else If "{1}" =~ /-near/ Set model "-model near" Else If "{1}" =~ /-far/ Set model "-model far" Else If "{1}" =~ /-noMerge/ Set NoMerge 1 Else If "{1}" =~ /-powerpc/ Set PPC 1 Else If "{1}" =~ /-68K/ Set PPC 0 Else If "{1}" =~ /-makesym/ Set MakeSymOptions "{2}"; Shift 2; Continue Else If "{1}" =~ /-makepef/ Set MakePefOptions "{2}"; Shift 2; Continue Else If "{1}" =~ /-map/ Set MapFile "{2}"; Shift 2; Set UsrMap 1; Continue Else If "{1}" =~ /-sym/ If "{2}" =~ /on/ Set Symbols 1 Set SymOption "-sym on" Else If "{2}" =~ /off/ Set Symbols 0 Else Set Error 1 Break; End Shift Else If "{1}" =~ /-symfile/ Set SymFile "{2}"; Shift 2; Continue Else If "{1}" =~ /-xcoffsymfile/ Set XCoffSymFile 1 Else If "{1}" =~ /-oldPPCLink/ Set PPCLinkOpts "" Else Set Error 1 Break; End Shift End If "{MapFile}" == "" Set MapFile "{Scratch}SharedLibTemp.Map" Set UsrMap 0 End If "{InObj}" == "" || "{OutFile}" == "" Set Error 1 End If {Error} Echo "Usage: LinkSharedLibrary -lib <OutputLibrary>" Echo " -obj <ObjectRootName>" Echo " -sym on|off -symfile <ObjectRootName> -xcoffsymfile" Echo " -map <MapFileName> -oldPPCLink" Echo " -noMerge -powerpc -68k" Echo " -link <Parameters for the link>" Echo "" Echo "Must be used after using BuildSharedLibrary" Echo "" Echo " The name after the -obj flag describes the base name for all of" Echo " the files resulting from invoking this tool. The following" Echo " are added to the base name you supply:" Echo " .lib.o - The actual shared library object file" Echo " .libr.r - Resource to rez with the shared library resource" Echo " .deps - File used to create the dependency ('libi') resource" Echo " .init.o - Initialization code for the library\n" Echo " .ia.o - Initialization code for the library\n" Echo " This should be the same name you passed to the BuildSharedLibrary" Echo " Script" Echo "" Echo " Everything after -link will be passed to the linker directly." Echo " The list of libraries to link with must be last" Echo " or after the -link switch." Echo " The link automatically merges segments Main, STDCLIB, STDIO," Echo " CSANELib, SANELIB, %Complex, SADEV, and INTENV unless you" Echo " specify the NoMerge flag" Exit 10 End If {Progress} Echo "∂t∂tCreating shared library ∂"{OutFile}∂"" End If NOT {NoMerge} && NOT {PPC} Set SegMerge "-sg Main=%Complex,CSANELib,CTYPE,INTENV,SADEV,SANELIB,SCCOMPLEX,SCMATH,SCMEM,SCPP,SCSTDIO,SCSTREAM,SCSTRING,SCTIME,STDCLIB,STDIO,ZMEM,ZPAGE,ZSTRING,ZTIME,ZZTC" Else Set SegMerge "" End delete -i "{Scratch}SharedLibTemp.libr.r" "{Scratch}SharedLibTemp.RSRC" "{Scratch}SharedLibTemp.pef" SetFile -c 'MPS ' -t TEXT "{InObj}.libr.r" duplicate -y "{InObj}.libr.r" "{Scratch}SharedLibTemp.libr.r" Delete -i "{Scratch}SharedLibTemp.RSRC.SYM" If "`Exists -f "{InObj}.deps"`" Set HaveDeps 1 Else Set HaveDeps 0 End If {WantProg} Echo "∂t∂t# Linking Library resource" End Set AsmInitFile "" If "`Exists "{InObj}.ia.o"`" Set AsmInitFile "{InObj}.ia.o" End Set Result 0 If {PPC} If {UsrMap} || {HaveDeps} Set MapOption "-map ∂"{MapFile}∂"" End PPCLink {PPCLinkOpts} {SymOption} -w -main DynamicCodeEntry -o "{Scratch}SharedLibTemp.xcoff" ∂ "{InObj}.init.o" "{AsmInitFile}" "{InObj}.lib.o" ∂ {MapOption} {"Parameters"} || Set Result {Status} If {Result} == 0 makepef "{Scratch}SharedLibTemp.xcoff" -o "{Scratch}SharedLibTemp.pef" ∂ -l StdCLib.xcoff=StdCLib -l InterfaceLib.xcoff=InterfaceLib -l MathLib.xcoff=MathLib ∂ {MakePefOptions} || Set Result {Status} If {Result} == 0 && {Symbols} && !{XCoffSymFile} MakeSym {MakeSymOptions} -o "{Scratch}SharedLibTemp.RSRC.SYM" "{Scratch}SharedLibTemp.xcoff" SetFile -c 'R2Db' -t 'MPSY' "{Scratch}SharedLibTemp.RSRC.SYM" End End Else If {UsrMap} || {HaveDeps} Set MapOption "-map >∂"{MapFile}∂"" End Link {model} {SymOption} -mf -d -t rsrc -c RSED ∂ -sg %A5Init=A5Init -ra %A5Init=resLocked -m DynamicCodeEntry ∂ -o "{Scratch}SharedLibTemp.RSRC" ∂ "{InObj}.init.o" "{AsmInitFile}" "{InObj}.lib.o" ∂ {SegMerge} {"Parameters"} {MapOption} || Set Result {Status} End If {Result} == 0 If {HaveDeps} If {PPC} "{SLMTools}CreateLibraryLoadRsrcPPC" -map "{Scratch}SharedLibTemp.xcoff" -out "{Scratch}SharedLibTemp.libr.r" ∂ -resid SLMID -a -readx "{InObj}.deps" Else "{SLMTools}CreateLibraryLoadRsrc" -map "{MapFile}" -out "{Scratch}SharedLibTemp.libr.r" ∂ -resid SLMID -a -readx "{InObj}.deps" End End duplicate -y "{Scratch}SharedLibTemp.libr.r" "{InObj}.libr.r" If {Symbols} && {XCoffSymFile} duplicate -y "{Scratch}SharedLibTemp.xcoff" "{SymFile}" delete -i -y "{Scratch}SharedLibTemp.xcoff" End If ("`Exists -f "{Scratch}SharedLibTemp.RSRC.SYM"`") && ("{SymFile}" !~ //) duplicate -y "{Scratch}SharedLibTemp.RSRC.SYM" "{SymFile}" Delete -i "{Scratch}SharedLibTemp.RSRC.SYM" End Delete -i "{OutFile}" ∑∑ Dev:Null If {PPC} Echo "read SLMType (SLMID, SLMName, purgeable) ∂"{Scratch}SharedLibTemp.pef∂";" >> "{Scratch}SharedLibTemp.libr.r" Else Echo "Include ∂"{Scratch}SharedLibTemp.RSRC∂" 'CODE' as SLMType;" >> "{Scratch}SharedLibTemp.libr.r" Echo "Delete SLMType (∂"32-bit bootstrap∂");" >> "{Scratch}SharedLibTemp.libr.r" End Rez -a -t libr -c OMGR -rd ∂ -o "{OutFile}" "{Scratch}SharedLibTemp.libr.r" SetFile -a ib "{OutFile}" End delete -i "{Scratch}SharedLibTemp.libr.r" "{Scratch}SharedLibTemp.RSRC" "{Scratch}SharedLibTemp.pef" If {HaveDeps} != 0 AND {UsrMap} == 0 Delete -i "{MapFile}" End exit {Result}